function ajax(url,callback,method){
  var xhr = new XMLHttpRequest();
  xhr.open(method,url);
  xhr.send();
  xhr.addEventListener("readystatechange",function(){
    if(xhr.readyState == 4 && xhr.status == 200){
      callback(JSON.parse(xhr.responseText));
    }
  })
}